//
//  LTHTTPTool.h
//  LTIM
//
//  Created by 俊松何 on 2017/3/30.
//  Copyright © 2017年 俊松何. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MJExtension.h"
//#import "UpdateModel.h"
@class LTBaseDataModel,LTFileTokenModel,LTError,LTUser;

typedef void(^ltsuccess)(LTBaseDataModel *datamodel);
typedef void(^ltparmerror)(LTBaseDataModel *datamodel);
typedef void(^ltfailer)(NSError *error);



#ifdef CherryChat

static NSString *basePath = @"http://mituim.108usd.com";

#else

static NSString *basePath = @"http://mituim.108usd.com";

#endif
//static NSString *basePath = @"http://ltapitest.mmcoco.com";
static NSString *md5key  = @"78nXdagKihv7ciyr";
typedef enum{
    FileTypeNormal = 1,
    FileTypeVoice  = 2,
    FileTypeVideo  = 3,
    FileTypeFile   = 4,
}FileType;


@interface LTHTTPTool : NSObject

+(instancetype)shareTool;

-(NSURLSessionDataTask *)lt_postPath:(NSString *)path
                          parameters:(NSDictionary *)parameters
                             success:(ltsuccess)success
                           parmerror:(ltparmerror)parmerror
                              failer:(ltfailer)failer;

-(NSURLSessionDataTask *)lt_getPath:(NSString *)path
                         parameters:(NSDictionary *)parameters
                            success:(ltsuccess)success
                          parmerror:(ltparmerror)parmerror
                             failer:(ltfailer)failer;


-(NSURLSessionDataTask *)postPath:(NSString *)path
                       parameters:(NSDictionary *)parameters
                          success:(ltsuccess)success
                        parmerror:(ltparmerror)parmerror
                           failer:(ltfailer)failer;


-(NSURLSessionDataTask *)getPath:(NSString *)path
                      parameters:(NSDictionary *)parameters
                         success:(ltsuccess)success
                       parmerror:(ltparmerror)parmerror
                          failer:(ltfailer)failer;

-(NSURLSessionDataTask *)deletePath:(NSString *)path
                         parameters:(NSDictionary *)parameters
                            success:(ltsuccess)success
                          parmerror:(ltparmerror)parmerror
                             failer:(ltfailer)failer;


-(void)getAppInfoComplete:(void(^)(BOOL needUpate,LTError *error))completeBlock;

//得到文件的token
-(void)getUploadTokenWithType:(FileType)type
                      success:(void(^)(LTFileTokenModel *model))success
                       failer:(void(^)(LTError *lterror))failer;

//得到网易文件的token
-(void)getUploadTokenWithType:(FileType)type
                     fileName:(NSString *)fileName
                      success:(void(^)(LTFileTokenModel *model))success
                       failer:(void(^)(LTError *lterror))failer;


//上传文件
-(void)uploadFileData:(NSData *)data
             FileType:(FileType)type
            progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))uploadProgress
            success:(void(^)(NSString *fileUrl,LTFileTokenModel *model))success
             failer:(void(^)(LTError *lterror))failer;
//上传图片
-(void)uploadImageData:(NSData *)data
              progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))uploadProgress
               success:(void(^)(NSString *fileUrl,LTFileTokenModel *model))success
                failer:(void(^)(LTError *lterror))failer;
//上传多张图片
-(void)uploadImages:(NSArray *)images
           complete:(void(^)(NSArray<NSString *> *names, BOOL state))complete;

////上传声音
//-(void)uploadVoiceData:(NSData *)data
//              progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))uploadProgress
//               success:(void(^)(NSString *remotePath,LTFileTokenModel *model))success
//                failer:(void(^)(LTError *lterror))failer;


////下载音频文件
//-(void)downloadVoiceData:(LTFileTokenModel *)ossmodle
//                progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))downloadProgress
//                 success:(void(^)(NSData *data))success
//                  failer:(void(^)(LTError *lterror))failer;
//
//
////下载封面图
//-(void)downloadImageData:(LTFileTokenModel *)ossmodle
//             isthumbnail:(BOOL)isthumbnail
//                    progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))downloadProgress
//                     success:(void(^)(NSData *data))success
//                      failer:(void(^)(LTError *lterror))failer;
//
////下载视频
//-(void)downloadVideoData:(LTFileTokenModel *)ossmodle
//                progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))downloadProgress
//                 success:(void(^)(NSData *data))success
//                  failer:(void(^)(LTError *lterror))failer;
//
////下载文件
//-(void)downloadFileData:(LTFileTokenModel *)ossmodle
//               progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))downloadProgress
//                success:(void(^)(NSData *data))success
//                 failer:(void(^)(LTError *lterror))failer;


//根据url下载文件
-(void)downloadFile:(NSString *)filePath
             suffix:(NSString *)suffix
           progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))progress
            success:(void(^)(NSData *data))success
             failer:(void(^)(LTError *lterror))failer;

//自动登录时获取用户信息
-(void)getSelfUserInfoWithCompletion:(void(^)(LTUser *user,LTError *lterror))completionblock;


//翻译接口的封装
-(void)translateWith:(NSString *)string
                  to:(NSString *)des
              result:(void(^)(NSString * result, LTError *error))completeBlock;



-(NSString *)MD5StringForString:(NSString *)str;


@end
